<!DOCTYPE html>
<html lang="en">
	<head>
		<title> New Document </title>
		<meta charset="utf-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- Bootstrap -->
		<link href="${webRoot}resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
		<link href="${webRoot}resources/css/style.css" rel="stylesheet">
		<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
		<style type="text/css">
		.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.80;
		filter: alpha(opacity=80);
		}
		.white_content {
		display: none;
		position: absolute;
		top: 10%;
		left: 10%;
		width: 80%;
		height: 80%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
		.white_content_small {
		display: none;
		position: absolute;
		top: 20%;
		left: 30%;
		width: 40%;
		height: 50%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
	</style>
	</head>
<body class="main">
	<div class="wrap">
	<ul class="breadcrumb">
		    <li><span id="test">您当前的位置：</span><a href="#">首页</a> <span class="divider">>></span></li>
		    <li class="active">${orderList}</li>
	     </ul>
		<div class="">
			<form class="form-inline">
				<input type="text" class="input-small" placeholder="订单号" id="order_no">
					<select class="select" id="order_status" name="order_status" onchange="changResult();">
					  <option value="">所有</option>
					  <option value="Y">已付款</option>
					  <option value="N">未付款</option>
					</select>
					<select class="select" id="order_result" name="order_result">
					  <option value="">所有</option>
					  <option value="N1">等待付款</option>
					  <option value="D1">已退单</option>
					  <option value="D2">已退单，未退款</option>
					  <option value="D2">已退单，已退款</option>
					</select>				
				<button type="button" class="btn" onclick="serachHref();">搜索</button>
				<button type="button" class="btn" onclick="setNull();">重置</button>
			</form>
		</div>
		<div id ="div">
		<div>
			<table class="table table-bordered table-striped table-hover">
				<thead>
					<tr>
						<th>订单号</th>
						<th>订单名称</th>
						<th>购买数量</th>
						<th>单价</th>
						<th>总金额</th>
						<th>下单时间</th>
						<th>支付状态</th>
						<th>订单状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#if listOrder?exists>
				<#list listOrder as orderEntity>
					<tr>
						<td>${orderEntity.order_no}</td>
						<td>${orderEntity.group_name}</td>
						<td>${orderEntity.buy_count}</td>
						<td>${orderEntity.groupprice}</td>
						<td>${orderEntity.order_price}</td>
						<td>${orderEntity.order_date?string("yyyy-MM-dd")}</td>
						<#if orderEntity.order_statu == "Y">
						<td>已付款</td>
						<#else>
						<td>未付款</td>
						</#if>
						<#if orderEntity.order_result == "N1">
						<td>等待付款</td>
						<#elseif orderEntity.order_result == "D1">
						<td>已退单</td>
						<#elseif orderEntity.order_result == "D2">
						<td>已退单，未退款</td>
						<#elseif orderEntity.order_result == "D3">
						<td>已退单，已退款</td>
						<#else>
						<td>交易完成</td>
						</#if>
						<td><a href="javascript:getOrderInfo(${orderEntity.order_id},${orderEntity.group_id},${orderEntity.member_id});">详情</a></td>
					</tr>
				 </#list>
				 <#else>
				   	 <tr>
				       <td colspan="8">没有查询到记录！</td>
				   </tr>
				</#if>
				</tbody>
			</table>			
		</div>
		<#if listOrder?exists>
		<div class="pagination pagination-right">
		  <input type="hidden" name="serchOrderNo" id="serchOrderNo" value="${serchOrderNo}"/>
		  <input type="hidden" name="serchStatus" id="serchStatus" value="${serchStatus}"/>
		  <input type="hidden" name="serchResult" id="serchResult" value="${serchResult}"/>
		  <ul>
		    <#if pageEntity.page==1>
		    <li class="disabled"><a href="#">&laquo;</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page-1},${pageEntity.totalPage},${pageEntity.pageSize})">&laquo;</a></li>
		    </#if>
		    <#list 1..pageEntity.totalPage as i>
		         <#if pageEntity.page==i>
		    <li class="active"><a href="#">${i}</a></li>
		         <#else>
		    <li><a href="javascript:pageHref(${i},${pageEntity.totalPage},${pageEntity.pageSize})">${i}</a></li>
		        </#if>
		    </#list>
		   <#if pageEntity.page==pageEntity.totalPage>
		    <li class="disabled"><a href="#">»</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page+1},${pageEntity.totalPage},${pageEntity.pageSize})">»</a></li>
		    </#if>
		  </ul>
		</div>
		</#if>		
		</div>	
	</div>			
	<!--弹出层时背景层DIV-->
<div id="fade" class="black_overlay">
</div>
<div id="MyDiv" class="white_content">
</div>
	<script src="${webRoot}resources/js/bootstrap.min.js"></script>
	<script src="${webRoot}resources/js/js.js"></script>
	<script type="text/javascript">
	function pageHref(page,totalPage,pageSize){
    	var orderNo = $("#serchOrderNo").val();
		var orderStatus = $("#serchStatus").val();
		var orderResult = $("#serchResult").val();
    	$.ajax({url:"${webRoot}order/getAjaxOrder.do?page="+page+"&pageSize="+pageSize+
    			"&totalPage="+totalPage+"&order_no="+orderNo+"&order_statu="+orderStatus
    			+"&order_result="+orderResult,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#div").html(msg);
			   }
			});
    }
	function serachHref(){
    	var orderNo =$("#order_no").val();
		var orderStatus = $("#order_status").val();
		var orderResult = $("#order_result").val();
    	$.ajax({url:"${webRoot}order/getAjaxOrder.do?order_no="+orderNo+"&order_statu="+orderStatus
			+"&order_result="+orderResult,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#div").html(msg);
			   }
			});
    }
	
	function changResult(){
		var orderStatu = $("#order_status").val();
		var context;
		if(orderStatu =='Y'){
			context = '<option value="">所有</option><option value="D2">已退单，未退款</option><option value="D2">已退单，已退款</option>';
			$("#order_result").html(context);
		}
		if(orderStatu =='N'){
 			context = '<option value="">所有</option><option value="N1">等待付款</option><option value="D1">已退单</option>';
			$("#order_result").html(context);
		}
		if(orderStatu==null || orderStatu==''){
			context = '<option value="">所有</option><option value="N1">等待付款</option><option value="D1">已退单</option><option value="D2">已退单，未退款</option><option value="D2">已退单，已退款</option>';
			$("#order_result").html(context);
		}
	}
	
	function getOrderInfo(orderId,groupId,membeId){
		$.ajax({url:"${webRoot}order/getOrderInfo.do?order_id="+orderId+"&group_id="+groupId
			+"&member_id="+membeId,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	
	function setNull(){
		$("#order_no").val("");
		$("#order_status").val("");
		$("#order_result").val("");
	}
	
	//弹出隐藏层
	function ShowDiv(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;
	// bgdiv.style.height = $(document).height();
	$("#"+bg_div).height($(document).height());
	};
	//关闭弹出层
	function CloseDiv(show_div,bg_div)
	{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
	};
	</script>
</body>
</html>
